package com.todo.strategy.online.application.frontend.controller;

import com.todo.common.common.entity.response.BizResponse;
import com.todo.strategy.online.application.frontend.service.PlanRelationAggService;
import com.todo.strategy.online.iface.PlanRelationFrontendIface;
import com.todo.strategy.online.iface.request.*;
import com.todo.strategy.online.iface.response.PlanRelationDetailVO;
import com.todo.strategy.online.iface.response.SamplePlanSetVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/5/19 14:31
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/strategy")
@Tag(name = "清单关联信息前台接口", description = "清单关联信息前台接口")
public class PlanRelationFrontendController implements PlanRelationFrontendIface {

    @Resource
    private PlanRelationAggService planRelationAggService;

    @Override
    @Operation(summary = "插入清单计划关联详情")
    @PostMapping("/insertPlanRelation")
    public BizResponse<Boolean> insertPlanRelation(InsertPlanRelationParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planRelationAggService.insertPlanRelation(param);
    }

    @Override
    @Operation(summary = "复制保存清单计划关联详情")
    @PostMapping("/duplicatePlanRelation")
    public BizResponse<Boolean> duplicatePlanRelation(DuplicatePlanRelationParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planRelationAggService.duplicatePlanRelation(param);
    }

    @Override
    public BizResponse<Boolean> duplicatePlanSet(DuplicatePlanSetParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planRelationAggService.duplicatePlanSet(param);
    }

    @Override
    @Operation(summary = "更新清单计划关联详情")
    @PostMapping("/updatePlanRelation")
    public BizResponse<Boolean> updatePlanRelation(UpdatePlanRelationParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planRelationAggService.updatePlanRelation(param);
    }

    @Override
    @Operation(summary = "删除清单计划关联详情")
    @PostMapping("/removePlanRelation")
    public BizResponse<Boolean> removePlanRelation(RemovePlanRelationParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planRelationAggService.removePlanRelation(param);
    }

    @Override
    @Operation(summary = "构造示例计划清单信息")
    @PostMapping("/buildSamplePlanSetInfo")
    public BizResponse<SamplePlanSetVO> buildSamplePlanSetInfo(SamplePlanSetInfoParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planRelationAggService.buildSamplePlanSetInfo(param);
    }

    @Override
    @Operation(summary = "根据清单计划查询详情列表")
    @PostMapping("/queryPlanRelationByPlanId")
    public BizResponse<PlanRelationDetailVO> queryPlanRelationByPlanId(QueryPlanRelationByPlanIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planRelationAggService.queryPlanRelationByPlanId(param);
    }

}
